﻿using BLL;
using IBLL;
using Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1.登录老师账号界面
{
    public partial class BulkImport : Form
    {
        IFrStudentManage_IBLL frStudent = new FrStudentManage_BLL();
        List<Students_MD> Students = null;
        bool kai = false;
        public BulkImport(string path)
        {
            InitializeComponent();
            dataGridView1.AutoGenerateColumns = false;
            try
            {
                Students = frStudent.GetStudentsFromExcel(path);
                dataGridView1.DataSource = Students;
            }
            catch (Exception ex)
            {
                MessageBox.Show("导入失败 错误信息:"+ex.Message);
                kai = true;
            }
          
           
        }

        private void butReturn_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void AddStudentss_Click(object sender, EventArgs e)
        {
            if (dataGridView1 == null && dataGridView1.Rows.Count == 0)
            {
                return;
            }
            try
            {
                frStudent.AddStudentsFromExcel(Students);
                this.DialogResult = DialogResult.OK;
                MessageBox.Show("考生信息导入成功","温馨提示");
            }
            catch (Exception ex)
            {

                MessageBox.Show("考生信息导入失败 错误信息："+ ex.Message,"温馨提示");
            }
            

        }

        private void BulkImport_Paint(object sender, PaintEventArgs e)
        {
            if (kai)
            {
                this.Close();
            }
        }
    }
}
